package pobidz;

import com.sun.org.apache.bcel.internal.classfile.Code;

public class ComplexPoint {

	
	private double real;
	private double imaginary = 0.0;
	
	
	public ComplexPoint(double real, double imaginary)
	{
		this.real = real;
		this.imaginary = imaginary;
	}

	public double getReal() {
		return real;
	}

	public void setReal(double real) {
		this.real = real;
	}

	public double getImaginary() {
		return imaginary;
	}

	public void setImaginary(double imaginary) {
		this.imaginary = imaginary;
	}
	
	public double magnitude()
	{
		return Math.sqrt(real*real + imaginary*imaginary);
	}
	
	
	public double phase()
	{ 
		double real2 = real; 
		double imaginary2 = imaginary;
		
		if (real < 0.001)
		{
			real2 = 0;
		}
		if (imaginary < 0.001)
		{
			imaginary2 = 0;
		}
		//return Math.pow(Math.tan(imaginary/real),-1);
		return Math.toDegrees(Math.atan2(imaginary2, real2));
	}
	    public ComplexPoint times(ComplexPoint b) {
        ComplexPoint a = this;
        double real = a.real * b.real - a.imaginary * b.imaginary;
        double imag = a.real * b.imaginary + a.imaginary * b.real;
        return new ComplexPoint(real, imag);
    }
	
}
